<template>
  <div class="w_full h_50 lh_50 flex_row_around flex_center absolute left_0 bottom_0 border_t_1_s_eee bgc_000">
    <van-tabbar v-model="activePage" active-color="orange" inactive-color="#fff">
      <van-tabbar-item @click="goToPage('/select-room')">
        <template #icon>
          <img :src="home" />
        </template>
        首页
      </van-tabbar-item>
      <van-tabbar-item @click="goToPage('/config')">
        <template #icon>
          <img :src="my" />
        </template>
        我的
      </van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
  export default {
    name: 'Tabbar',
    data() {
      return {
        activePage: '', 
        route: '',

        home: require('../assets/image/home.png'),
        my: require('../assets/image/my.png'),
      }
    },
    
    async mounted() {
      let route = this.$route.path
      this.route = route

      if (route == '/select-room') {
        this.activePage = 0
      } else if (route == '/config') {
        this.activePage = 1
      }
      
    },
    methods: {
      goToPage(path) {
        this.$router.push(path)
      }
    }
  }
</script>

<style>
  .van-tabbar-item { background-color: var(--sub-color) !important; }
</style>